import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_demo/float_screen/float_screen_track_view.dart';
import 'package:flutter_demo/float_screen/flyIn_out_widget.dart';

class FloatScreenContainer extends StatefulWidget {
  const FloatScreenContainer({super.key});

  @override
  State<FloatScreenContainer> createState() => _FloatScreenContainerState();
}

class _FloatScreenContainerState extends State<FloatScreenContainer> {
  @override
  Widget build(BuildContext context) {
    // return FlyInOutWidget(child: SizedBox(
    //   width: double.infinity,
    //   height: 46,
    //   child: Stack(children: [FloatScreenTrackView()]),
    // )) ;

    return SizedBox(
          width: double.infinity,
          height: 46,
          child: Stack(children: [FloatScreenTrackView()]),
        )
        .animate(
          onPlay: (controller) => controller.repeat(), // 设置循环播放 [1](@ref)
        )
        .slide(
          begin: const Offset(1.0, 0.0),
          end: Offset.zero,
          duration: 250.ms,
        ) // 飞入效果：0.25秒淡入
        .then(delay: 2000.ms) // 停留2秒 [1](@ref)
        .slide(
          begin: Offset.zero,
          end: const Offset(-1.0, 0.0),
          duration: 250.ms,
        );
  }
}
